/** signals.d - A Signal/Slot Pattern Implemention

Authors:	
	Wei Li (oldrev@gmail.com)

Copyright:	
	Copyright (C) 2007 Wei Li.

License:	
	BSD

*/

module samples.base.signals;

import dotmars.base.signals;
import dotmars.io.console;

void main()
{
	class Window
	{
		bool pressed;

		this()
		{ pressed = false; }

		Signal!() clickSignal;
	}

	auto w = new Window;

	void onClick1() { 
		w.pressed = true; 
		Console.writeLine("onClick1"); 
	}

	void onClick2() {  
		Console.writeLine("onClick2"); 
	}

	w.clickSignal += &onClick1;
	w.clickSignal += &onClick2;

	assert(w.clickSignal.connected(&onClick1));
	assert(w.clickSignal.connected(&onClick2));

	w.clickSignal(); //Fire the event

	assert(w.pressed);

}
